<!DOCTYPE html>
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
    <div class="append">
        <p>A</p><p><span>B</span></p>
    </div>
    <div class="prepend">
        <p>A</p><p><span>B</span></p>
    </div>
    <script>$(".append p").append("<span>C</span>");$(".prepend p").prepend("<span>C</span>");</script>
</body>
</html>